package ru.moek.entity;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

public class DBEntityManager {
    private static EntityManager entityManager;
    private static EntityManagerFactory entityManagerFactory;
    private   static String shema;
    
    public static String getShema() {
        return shema;
        
    }

    public static void setShema(String shema) {
        DBEntityManager.shema = shema;
        entityManagerFactory = Persistence
		.createEntityManagerFactory(shema);
    }

    DBEntityManager(){
	setShema("PHONEACCOUNT");
        entityManager = entityManagerFactory.createEntityManager();
    }
    
    public void beginTransaction(){
	entityManager.getTransaction().begin();
    }
    
    public void endTransaction(){
	entityManager.getTransaction().commit();
    }
    
    public void UPDATE(EntityManager value){
	entityManager.merge(value);
    }
}
